var mongoose = require('mongoose');

mongoose.dbinit = function(host, port, name){
    var url = 'mongodb://' + host + ':' + port + '/' + name;
    mongoose.connect(url);
}

mongoose.connection.on('connected', function () {
    console.log('Mongoose connected!');
});

mongoose.connection.on('error',function (err) {
    console.log('Mongoose connection error: ' + err);
});

mongoose.connection.on('disconnected', function () {
    console.log('Mongoose connection disconnected');
});

module.exports = mongoose;